package com.yyyit.bg2.run;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

import com.yyyit.bg2.controller.User;
import com.yyyit.bg2.controller.Goods;
//公共的业务如登录放在pub
import com.yyyit.bg2.pub.*;
//和业务无关的内容放在tools，例如线程等待，数据库的连接
import com.yyyit.bg2.tools.*;

public class Start {
	static Logger logger = LogManager.getLogger();

	public static void main(String args[]) {
		// System.setProperty("webdriver.firefox.bin",
		// "C:\\Program Files\\Firefox Developer Edition\\firefox.exe");
		WebDriver driver = new FirefoxDriver();
		// 更换环境时需要调整此处的链接和用户信息
		String baseUrl = "http://qaboss.qdingnet.com/";
		String userName = "admin", userPassword = "123456";
		logger.info(baseUrl);

		// 登录
		logger.info(Login.login(driver, baseUrl, userName, userPassword));

		tools.wait(3);

		// 添加用户
		String au = User.addUser(driver, baseUrl);
		if (!au.equals("添加用户失败")) {
			logger.info("添加用户成功");

			logger.info(User.searchAndDeleteUser(driver, baseUrl, au));
		}

		tools.wait(3);

		// TODO 添加商品
		// logger.info(Goods.addGood(driver, baseUrl));
		driver.quit();
		logger.info("萌萌哒自动化做完了。");
	}

}
